window.addEventListener("load",function(){
    // =================================================

    
    //获取元素
const poster1=document.querySelector(".poster1");
const poster2=document.querySelector(".poster2");
const poster3=document.querySelector(".poster3");
const spans=document.querySelectorAll(".poster-in span");
const ps=document.querySelectorAll(".poster-switcher span");
spans[0].style.backgroundColor="rgb(243, 166, 13";
// 添加定时器
let posTime=window.setInterval(function(){
    posTimes()
},3000);
let poster=0;
function posTimes(){
    if(poster==0){
        poster1.style.opacity="1";
        spans[0].style.backgroundColor="rgb(243, 166, 13";
        poster2.style.opacity="0";
        spans[1].style.backgroundColor="rgb(255, 255, 255)";
        poster3.style.opacity="0";
        spans[2].style.backgroundColor="rgb(255, 255, 255)";
           poster++;
         }
         else if(poster==1){
          poster1.style.opacity="0";
          spans[0].style.backgroundColor="rgb(255, 255, 255)";
         poster2.style.opacity="1";
         spans[1].style.backgroundColor="rgb(243, 166, 13";
         poster3.style.opacity="0";
         spans[2].style.backgroundColor="rgb(255, 255, 255)";
            poster++;
         }
         else if(poster==2){
         poster1.style.opacity="0";
         spans[0].style.backgroundColor="rgb(255, 255, 255)";
         poster2.style.opacity="0";
         spans[1].style.backgroundColor="rgb(255, 255, 255)";
         poster3.style.opacity="1";
         spans[2].style.backgroundColor="rgb(243, 166, 13";
             poster=0;
          }
   
};
function posTimes2(){
    if(poster==0){
        poster1.style.opacity="1";
        spans[0].style.backgroundColor="rgb(243, 166, 13";
        poster2.style.opacity="0";
        spans[1].style.backgroundColor="rgb(255, 255, 255)";
        poster3.style.opacity="0";
        spans[2].style.backgroundColor="rgb(255, 255, 255)";
       
         }
         else if(poster==1){
          poster1.style.opacity="0";
          spans[0].style.backgroundColor="rgb(255, 255, 255)";
         poster2.style.opacity="1";
         spans[1].style.backgroundColor="rgb(243, 166, 13";
         poster3.style.opacity="0";
         spans[2].style.backgroundColor="rgb(255, 255, 255)";
          
         }
         else if(poster==2){
         poster1.style.opacity="0";
         spans[0].style.backgroundColor="rgb(255, 255, 255)";
         poster2.style.opacity="0";
         spans[1].style.backgroundColor="rgb(255, 255, 255)";
         poster3.style.opacity="1";
         spans[2].style.backgroundColor="rgb(243, 166, 13";
        
        }
   
};
 
//添加点击事件
 ps[1].addEventListener("click",function(){
     window.clearInterval(posTime);
     posTimes();
     posTime=window.setInterval(function(){
          posTimes()
     },3000);
 });
ps[0].addEventListener("click",function(){
    window.clearInterval(posTime);
    poster--;
    if(poster<0){poster=2}
    posTimes2();
    posTime=window.setInterval(function(){
        posTimes()
    },3000);
    
});

// 海量的API鼠标移入移出事件==========================================
// 获取元素
const imgse=document.querySelectorAll(".hlAPI-nav li img");
const lis=document.querySelectorAll(".hlAPI-nav li");

let arr=[
"./imge/images/api01-c.svg",
"./imge/images/api02-c.svg",
"./imge/images/api03-c.svg",
"./imge/images/api04-c.svg",
"./imge/images/api05-c.svg",
"./imge/images/api06-c.svg",
"./imge/images/api07-c.svg",
"./imge/images/api08-c.svg",
"./imge/images/api01-c.svg",
"./imge/images/api01-c.svg",
];
imgse.forEach(function(v, i){
   let re="";
    lis[i].addEventListener("mouseover",function(){
        re=v.src;
     v.src=arr[i]
    });
    lis[i].addEventListener("mouseout",function(){
       v.src=re
    })

})






// 独角兽轮播图===================================================
// 获取元素
const nicornCom=document.querySelectorAll(".unicorn-company");
nicornCom[0].style.opacity=1;
// 添加定时器
let nicornComS=0;
window.setInterval(function(){
  
    for(let i=0 ;i<nicornCom.length;i++){
        nicornCom[i].style.opacity=0;
    }
    nicornCom[nicornComS].style.opacity=1;
    nicornComS++;
    if(nicornComS==nicornCom.length){
        nicornComS=0;
    }
},2000)


// ======================================================

})